package com.example.security;

import com.example.service.AuthService;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zihong.zheng
 * @version 1.0
 * @date 2018/4/18
 * @time 22:59
 * @description
 */
@Aspect
@Component
public class SecurityAspect {

    @Autowired
    AuthService authService;


    @Pointcut(value = "@annotation(com.example.service.AdminOnly)")
    public void adminOnly(){

    }

    @Before("adminOnly()")
    public void check(){
        authService.checkAccess();
    }
}
